<%@ page language="java" import="java.util.*" import="java.sql.*" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ page import="com.example.demo2.DBUtil" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>后台管理系统</title>
</head>
<link rel="stylesheet" href="css/bootstrap.css">
<body>
<style>
    .center{display: flex !important;align-content: center;justify-content: center;align-items: center;}
</style>
<div style="display: flex; justify-content: center;flex-direction: column;align-items: center;">
    <%@include file="admin_header.jsp"%>
    <div style="margin-top: 20px">

        <ul class="list-group list-group-horizontal">
            <li class="list-group-item" style="width: 50px">ID</li>
            <li class="list-group-item"style="width: 150px">用户名</li>
            <li class="list-group-item"style="width: 150px">商品名称</li>
            <li class="list-group-item"style="width: 150px">付款金额</li>
            <li class="list-group-item"style="width: 150px">操作</li>
        </ul>
        <%
            request.setCharacterEncoding("UTF-8");
            String a_name = request.getParameter("a_name");
            String a_pinp = request.getParameter("a_pinp");
            String a_xzq = request.getParameter("a_xzq");
            String a_leix = request.getParameter("a_leix");
            String a_fuw = request.getParameter("a_fuw");
            String a_jvli = request.getParameter("a_jvli");
            String a_qian = request.getParameter("a_qian");
            String a_dizhi = request.getParameter("a_dizhi");
            String a_phone = request.getParameter("a_phone");

            String u_id = request.getParameter("u_id");
            String u_name = request.getParameter("u_name");
            String u_pinp = request.getParameter("u_pinp");
            String u_xzq = request.getParameter("u_xzq");
            String u_leix = request.getParameter("u_leix");
            String u_fuw = request.getParameter("u_fuw");
            String u_jvli = request.getParameter("u_jvli");
            String u_qian = request.getParameter("u_qian");
            String u_dizhi = request.getParameter("u_dizhi");
            String u_phone = request.getParameter("u_phone");
            String d_id = request.getParameter("d_id");
            Connection cn = null;
            PreparedStatement ps = null;

            ResultSet rs = null;
            String sql = "";
            cn = DBUtil.getConnection();
            sql = "SELECT q.id,u.user u_user,s.name s_name,q.qian from qg_dd q JOIN user u on q.u_id = u.id JOIN shangp s on q.s_id = s.id";
            ps = cn.prepareStatement(sql);
            rs = ps.executeQuery();

            if (d_id != null){
                int n=0;
                sql = "DELETE FROM `gp`.`qg_dd` WHERE `id` = " + d_id;
//              System.out.println(sql);
                ps = cn.prepareStatement(sql);
                n= ps.executeUpdate();
                response.sendRedirect("ad_qg_dindan.jsp");
            }
            while(rs.next()){
                int id = rs.getInt("id");
                String u_user = rs.getString("u_user");
                String s_name = rs.getString("s_name");
                String qian = rs.getString("qian");
        %>
        <ul class="list-group list-group-horizontal-sm">
            <li class="list-group-item center"style="width: 50px;"><%=id%></li>
            <li class="list-group-item center"style="width: 150px"><%=u_user%></li>
            <li class="list-group-item center"style="width: 150px"><%=s_name%></li>
            <li class="list-group-item center"style="width: 150px"><%=qian%></li>
            <li class="list-group-item center"style="width: 150px">
                <a href="ad_qg_dindan.jsp?d_id=<%=id%>"
                   type="button"
                   class="btn btn-info btn-sm"
                   style="margin-bottom: 20px">发货</a>
            </li>
        </ul>

        <%
            }
        %>
    </div>

</div>
<script src="js/jQuery.js"></script>
<script src="js/bootstrap.js"></script>

</body>
</html>